package com.iweb.newa202104.controller;

import com.iweb.newa202104.dto.UserInputDTO;
import com.iweb.newa202104.service.UserService;
import com.iweb.newa202104.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;


/**
 * @Author: LGZ
 * @Date: 2021/5/9 22:06
 * @Description:
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/login")
    public ResultVO login(HttpSession session, @Validated @RequestBody UserInputDTO userInputDTO) {
        return userService.login(session, userInputDTO);
    }

    @PostMapping("/register")
    public ResultVO register(@Validated @RequestBody UserInputDTO userInputDTO) {
        return userService.register(userInputDTO);
    }



}
